package com.zygh.dlqwservice.module.controller.app;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zygh.dlqwservice.common.domain.ResultBeans;
import com.zygh.dlqwservice.common.domain.ResultUtils;
import com.zygh.dlqwservice.constant.SwaggerTagConst;
import com.zygh.dlqwservice.module.entity.Special;
import com.zygh.dlqwservice.module.entity.Sptype;
import com.zygh.dlqwservice.module.service.ISpecialService;
import com.zygh.dlqwservice.module.service.ISptypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 特殊勤务
 * @author lee
 */
@Api(tags = SwaggerTagConst.Admin.MANAGER_APP_SPECIAL)
@RestController
@RequestMapping("/app/special")
public class AppSpecialController {
    @Resource
    private ISptypeService iSptypeService;
    @Resource
    private ISpecialService iSpecialService;

    /**
     * 展示一级勤务
     * @return ResultBeans
     */
    @PostMapping("/show/one")
    @ApiOperation("显示特殊勤务一级")
    public ResultBeans one(){
        List<Sptype> data = iSptypeService.list(Wrappers.<Sptype>lambdaQuery().exists("select * from special where special.sptype_id = sptype.type "));
        return ResultUtils.resultBeansSuccess(data);
    }

    /**
     * 展示二级勤务
     * @param sptype 封装参数
     * @return ResultBeans
     */
    @PostMapping("/show/two")
    @ApiOperation("显示特殊勤务二级")
    public ResultBeans two(@RequestBody Sptype sptype){
        return iSpecialService.getSpecial(sptype);
    }

    /**
     * 展示详细勤务
     * @param special 封装参数
     * @return ResultBeans
     */
    @PostMapping("/show/three")
    @ApiOperation("显示详细勤务")
    public ResultBeans detail(@RequestBody Special special){
        List<Special> data = iSpecialService.list(Wrappers.<Special>lambdaQuery().eq(Special::getHierarchy, special.getHierarchy()));
        return ResultUtils.resultBeansSuccess(data);
    }
}
